// phalanx operators.hpp.cu header file

// Copyright (c) 2011 - 2011 Kohei Takahashi (Flast).
// Distributed under the MIT license. for more detail see COPYING.

// Redefinition std::complex (C++0x's)

#ifndef IG_PHALANX_MATH_COMPLEX_OPERATORS_HPP_CU_ONCE_
#define IG_PHALANX_MATH_COMPLEX_OPERATORS_HPP_CU_ONCE_

#include <phalanx/config.hpp.cu>

#include <phalanx/math/complex/complex_fwd.hpp.cu>

namespace phalanx
{

namespace math
{

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator+( const complex< T > &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp += y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator+( const complex< T > &x_, const T &y_ )
{
    complex< T > tmp( x_ );
    tmp += y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator+( const T &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp += y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator-( const complex< T > &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp -= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator-( const complex< T > &x_, const T &y_ )
{
    complex< T > tmp( x_ );
    tmp -= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator-( const T &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp -= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator*( const complex< T > &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp *= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator*( const complex< T > &x_, const T &y_ )
{
    complex< T > tmp( x_ );
    tmp *= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator*( const T &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp *= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator/( const complex< T > &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp /= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator/( const complex< T > &x_, const T &y_ )
{
    complex< T > tmp( x_ );
    tmp /= y_;
    return tmp;
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
complex< T >
operator/( const T &x_, const complex< T > &y_ )
{
    complex< T > tmp( x_ );
    tmp /= y_;
    return tmp;
}

template < typename T >
complex< T >
operator+( const complex< T > &x_ )
{ return complex< T >( x_ ); }

template < typename T >
complex< T >
operator-( const complex< T > &x_ )
{ return complex< T >( -x_.real(), -x_.imag() ); }

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator==( const complex< T > &x_, const complex< T > &y_ )
{
    return x_.real() == y_.real()
        && x_.imag() == y_.imag();
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator==( const complex< T > &x_, const T &y_ )
{ return x_ == complex< T >( y_ ); }

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator==( const T &x_, const complex< T > &y_ )
{ return complex< T >( x_ ) == y_; }

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator!=( const complex< T > &x_, const complex< T > &y_ )
{
    return x_.real() != y_.real()
        || x_.imag() != y_.imag();
}

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator!=( const complex< T > &x_, const T &y_ )
{ return x_ != complex< T >( y_ ); }

template < typename T >
PHALANX_CONFIG_DEFAULT_FUNCTION( true )
bool
operator!=( const T &x_, const complex< T > &y_ )
{ return complex< T >( x_ ) != y_; }

} // namespace math

} // namespace phalanx

#endif // IG_PHALANX_MATH_COMPLEX_OPERATORS_HPP_CU_ONCE_

